import random

min,max=1,20
ans = random.randint(min,max)
money = 5000
playnum = 0

while True:
        yourNum = int(input("猜猜1~20之间的数字："))
        if yourNum == ans:
            print("恭喜你，答对了！")
            money += 3000
            playnum += 1
            todo = int(input("do you wanna continue ,please input 1/0:"))
            if todo == 1:
                print("继续玩吧")
            else:
                break

        elif yourNum < ans:
            print("小了")
            money -= 500
            print("余额还有：",money)
            if money < 0:
                print("no money to continue")
                playnum += 1
                break
        else:
            print("大了")
            money -= 500
            print("余额还有：",money)
            if money < 0:
                print("no money to continue")
                playnum += 1
                break

